import axios from 'axios';
export default class Ajax {
    public static async post(url, data?: object) {
        const params = new URLSearchParams();
        if (data) {
            for (const key in data) {
                if (data.hasOwnProperty(key)) {
                    params.append(key, data[key]);
                }
            }
        }
        const ret = await axios.post(url, params, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
        });
        return ret.data;
    }

    public static async get(url) {
        const ret = await axios.get(url);
        return ret.data;
    }

}
